// pages/shareOne/index.js
const app = getApp()
var rid;
var id;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hitenTop: false,
    userBasic: {},
    redPackAtil: {},
  },
  goUserInfo() {
    wx.switchTab({
      url: '../userInfo/index',
    })
  },
  //获取个人基本信息
  getUserBasicInfo: function() {
    var that = this;
    var data = [];
    var url = 'We_Community/getBrowsePersonalUserBasic'
    var calkdata = app.netWorkRequest(that, data, url, 'userBasic')
  },
  //提取当条红包记录
  getOneRedenvelopeReceive: function() {
    var that = this;
    var data = [];
    data['rid'] = rid;
    var url = 'We_Redenvelopes/getOneRedenvelopeLet';
    var calkdata = app.netWorkRequest(that, data, url, 'redPackAtil')
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    rid = options.rid;
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.getUserBasicInfo();
    this.getOneRedenvelopeReceive();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {
    var that = this;
    var t = that.data;
    var uid = t.userBasic['User_id'];
    var title = '[@你]联首名片给你发来了一个红包';
    var path = 'pages/visitorInfo/index?id=' + uid + '&sid=' + uid + '&rid=' + rid;
    var imageUrl = '';
    wx.showShareMenu({
      withShareTicket: true
    })
    that.setData({
      hitenTop: true
    })
    setTimeout(function() {
      that.setData({
        hitenTop: false
      })
    }, 3000)
    console.log('分享信息', path)
    return {
      title: title,
      path: path,
      // imageUrl: imageUrl,
    }
  }
})